home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr29 / memsize.zip / MUTEX.H < prev    next >
C/C++ Source or Header  |  1995-01-04  |  1KB  |  43 lines

  1. /******************************************************************** MUTEX.H
  2.  *                                                                          *
  3.  *  MUTEX Semaphore Class                                                   *
  4.  *                                                                          *
  5.  ****************************************************************************/
  6.  
  7. #ifndef MUTEX_H
  8. #define MUTEX_H
  9.  
  10. class Mutex
  11. {
  12.   private:
  13.     HMTX Handle ;
  14.  
  15.   public:
  16.     Mutex ( PSZ Name )
  17.     {
  18.       int Status = DosCreateMutexSem ( Name, &Handle, 0, FALSE ) ;
  19.       if ( Status )
  20.       {
  21.          extern VOID Log ( char *Message, ... ) ;
  22.          Log ( "MUTEX: Unable to create semaphore '%s'.\r\n", Name ) ;
  23.       }
  24.     }
  25.  
  26.     ~Mutex ( )
  27.     {
  28.       DosCloseMutexSem ( Handle ) ;
  29.     }
  30.  
  31.     int Request ( int Timeout )
  32.     {
  33.       return ( DosRequestMutexSem ( Handle, Timeout ) ) ;
  34.     }
  35.  
  36.     int Release ( )
  37.     {
  38.       return ( DosReleaseMutexSem ( Handle ) ) ;
  39.     }
  40. } ;
  41.  
  42. #endif
  43.